package add;

//import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import util.JdbcUtil;

public class Main_add
{
	private Connection conn = null;
	private PreparedStatement ps = null;
	private ResultSet rs = null;
	
	public Main_add()
	{
		conn = JdbcUtil.getConnection();
		String table = "main_info";
		String sql = "insert into "+table+" values(?,?,?,?,?,?,?,?,?)";
		try {
			ps = conn.prepareStatement(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	public int add(int ID,String NAME,String PSW,String QQ,String TEL,String MAIL,String LOCAL,String SEX,Date BIRTH)
	{
		int count = 0;
		try {
			ps.setInt(1, ID);
			ps.setString(2, NAME);
			ps.setString(3,PSW);
			ps.setString(4,QQ);
			ps.setString(5,TEL);
			ps.setString(6,MAIL);
			ps.setString(7,LOCAL);
			ps.setString(8,SEX);
			ps.setDate(9,BIRTH);
			count = ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally
		{
			JdbcUtil.release(conn, ps, rs);
		}
		return count;
	}
//	@SuppressWarnings("deprecation")
//	public static void main(String[] args)
//	{
//		Main_add a = new Main_add();
//		System.out.println(a.add(32, "name", "psw", null, "sss", "hh ", "家", "sd", new Date(1993, 12, 27)));
//		System.out.print(Charset.defaultCharset());
//	}
}
